/*     */ package com.cr.web.controller.system;
/*     */ 
/*     */ import com.cr.common.annotation.Log;
/*     */ import com.cr.common.core.controller.BaseController;
/*     */ import com.cr.common.core.domain.AjaxResult;
/*     */ import com.cr.common.core.page.TableDataInfo;
/*     */ import com.cr.common.enums.BusinessType;
/*     */ import com.cr.common.utils.poi.ExcelUtil;
/*     */ import com.cr.system.domain.SysPost;
/*     */ import com.cr.system.service.ISysPostService;
/*     */ import java.util.List;
/*     */ import org.apache.shiro.authz.annotation.RequiresPermissions;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.ui.ModelMap;
/*     */ import org.springframework.validation.annotation.Validated;
/*     */ import org.springframework.web.bind.annotation.GetMapping;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.PostMapping;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/system/post"})
/*     */ public class SysPostController extends BaseController {
/*  33 */   private String prefix = "system/post";
/*     */   
/*     */   @Autowired
/*     */   private ISysPostService postService;
/*     */   
/*     */   @RequiresPermissions({"system:post:view"})
/*     */   @GetMapping
/*     */   public String operlog() {
/*  42 */     return this.prefix + "/post";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:post:list"})
/*     */   @PostMapping({"/list"})
/*     */   @ResponseBody
/*     */   public TableDataInfo list(SysPost post) {
/*  50 */     startPage();
/*  51 */     List<SysPost> list = this.postService.selectPostList(post);
/*  52 */     return getDataTable(list);
/*     */   }
/*     */   
/*     */   @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
/*     */   @RequiresPermissions({"system:post:export"})
/*     */   @PostMapping({"/export"})
/*     */   @ResponseBody
/*     */   public AjaxResult export(SysPost post) {
/*  61 */     List<SysPost> list = this.postService.selectPostList(post);
/*  62 */     ExcelUtil<SysPost> util = new ExcelUtil(SysPost.class);
/*  63 */     return util.exportExcel(list, "岗位数据");
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:post:remove"})
/*     */   @Log(title = "岗位管理", businessType = BusinessType.DELETE)
/*     */   @PostMapping({"/remove"})
/*     */   @ResponseBody
/*     */   public AjaxResult remove(String ids) {
/*     */     try {
/*  74 */       return toAjax(this.postService.deletePostByIds(ids));
/*  76 */     } catch (Exception e) {
/*  78 */       return error(e.getMessage());
/*     */     } 
/*     */   }
/*     */   
/*     */   @GetMapping({"/add"})
/*     */   public String add() {
/*  88 */     return this.prefix + "/add";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:post:add"})
/*     */   @Log(title = "岗位管理", businessType = BusinessType.INSERT)
/*     */   @PostMapping({"/add"})
/*     */   @ResponseBody
/*     */   public AjaxResult addSave(@Validated SysPost post) {
/* 100 */     if ("1".equals(this.postService.checkPostNameUnique(post)))
/* 102 */       return error("新增岗位'" + post.getPostName() + "'失败，岗位名称已存在"); 
/* 104 */     if ("1".equals(this.postService.checkPostCodeUnique(post)))
/* 106 */       return error("新增岗位'" + post.getPostName() + "'失败，岗位编码已存在"); 
/* 108 */     post.setCreateBy(getLoginName());
/* 109 */     return toAjax(this.postService.insertPost(post));
/*     */   }
/*     */   
/*     */   @GetMapping({"/edit/{postId}"})
/*     */   public String edit(@PathVariable("postId") Long postId, ModelMap mmap) {
/* 118 */     mmap.put("post", this.postService.selectPostById(postId));
/* 119 */     return this.prefix + "/edit";
/*     */   }
/*     */   
/*     */   @RequiresPermissions({"system:post:edit"})
/*     */   @Log(title = "岗位管理", businessType = BusinessType.UPDATE)
/*     */   @PostMapping({"/edit"})
/*     */   @ResponseBody
/*     */   public AjaxResult editSave(@Validated SysPost post) {
/* 131 */     if ("1".equals(this.postService.checkPostNameUnique(post)))
/* 133 */       return error("修改岗位'" + post.getPostName() + "'失败，岗位名称已存在"); 
/* 135 */     if ("1".equals(this.postService.checkPostCodeUnique(post)))
/* 137 */       return error("修改岗位'" + post.getPostName() + "'失败，岗位编码已存在"); 
/* 139 */     post.setUpdateBy(getLoginName());
/* 140 */     return toAjax(this.postService.updatePost(post));
/*     */   }
/*     */   
/*     */   @PostMapping({"/checkPostNameUnique"})
/*     */   @ResponseBody
/*     */   public String checkPostNameUnique(SysPost post) {
/* 150 */     return this.postService.checkPostNameUnique(post);
/*     */   }
/*     */   
/*     */   @PostMapping({"/checkPostCodeUnique"})
/*     */   @ResponseBody
/*     */   public String checkPostCodeUnique(SysPost post) {
/* 160 */     return this.postService.checkPostCodeUnique(post);
/*     */   }
/*     */ }


/* Location:              D:\tmp\creditorRights-admin\BOOT-INF\classes\com.zip!\com\cr\web\controller\system\SysPostController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */